function [ F ] = prepareF(f, g, h, W)
%PREPAREF Summary of this function goes here
%   Detailed explanation goes here

if nargin == 3
    W = ones(size(g));
end

%size(f)
%size(g)
%size(W)

t = zeros(size(g, 1), size(g, 2));
t(2, :) = ((W(1 ,:) + W(2 ,:)) ./ 2) .* g(1 ,:);
t(end - 1, :) = t(end - 1, :) + (((W(end, :) + W(end - 1, :)) ./ 2) .* g(end, :));
t(:, 2) = t(:, 2) + (((W(:, 1) + W(:, 2)) ./ 2) .* g(:, 1));
t(:, end - 1) = t(:, end - 1) + (((W(:, end) + W(:, end - 1)) ./ 2).* g(:, end));
t = crop(t);
%f
%g
%t
%W
%h

F = reshape(f - (t ./ (h.^2)), size(f, 1) * size(f, 2), 1);

end
